package arithm

import (
	"testing"
)

func TestReadNumber(t *testing.T) {
	tests := []struct {
		input string
		want  string
	}{
		{"1", "1"},
		{"1/2", "1/2"},
		{"12.5", "12.5"},
		{"1+2i", "1+2i"},
		{"1i", "0+1i"},
		{"+i", "0+1i"},
		{"-i", "0-1i"},
		{"-1/2i", "0-0.5i"},
		{"1/4+1/2i", "0.25+0.5i"},
		{"-1/4-1/2i", "-0.25-0.5i"},
		{"123456789012345678901234567890", "123456789012345678901234567890"},
		{"4/123456789012345678901234567890", "2/61728394506172839450617283945"},
		{"4/123456+7890.12345678901234567890i", "3.240020736132711e-05+7890.123456789012i"},
		{"1+2e+1i", "1+20i"},
		{"1.5e-3+2e+1i", "0.0015+20i"},
	}
	for _, tt := range tests {
		got, err := ReadNumber(tt.input)
		if err != nil {
			t.Errorf("readNumber(%s) failed: %v", tt.input, err)
		}
		if got.String() != tt.want {
			t.Errorf("readNumber(%s) got %s, want %s", tt.input, got.String(), tt.want)
		}
	}
}
